/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2021-01-08
*/
package com.rzico.basics.controller;

import com.rzico.annotation.Log;
import com.rzico.base.BaseController;
import com.rzico.base.CommResult;
import com.rzico.basics.entity.ShopCategory;
import com.rzico.basics.entity.Supplier;
import com.rzico.basics.service.ShopCategoryService;
import com.rzico.core.entity.SysUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 店铺分类控制层
 *
 * @author Rzico Boot
 * @version 1.0
 * @date 2021-01-08
 */
@Api(description = "店铺分类接口")
@RestController
@RequestMapping("/shopCategory")
public class ShopCategoryController extends BaseController {

    @Autowired
    private ShopCategoryService shopCategoryService;

    /**
     * 分页查询产品分类
     *
     * @return
     */
    @ApiOperation("分页查询产品分类")
    @GetMapping("/list")
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "分类ID", dataType = "Long", paramType = "query"),
            @ApiImplicitParam(name = "scopeType", value = "经营范围 {0:其他,1:餐饮,2:酒店,3:名厨,4.餐车}", dataType = "Long", paramType = "query")
    })
    public CommResult<ShopCategory> list(Long id,Long scopeType) {
        Map<String, Object> params = new HashMap<String, Object>();

        if (null != id){
            params.put("treePath", id);
        }

        if (null != scopeType){
            params.put("scopeType", scopeType);
        }

        params.put("sortField", "tree_path");
        params.put("sortType", "asc");
        List<ShopCategory> list = shopCategoryService.selectTree(params);
        return CommResult.success(list);

    }


}
